package dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import pojo.Carousel;

import java.util.List;

public interface CarouselMapper {
    @Select("SELECT * FROM carousel")
    List<Carousel> findAll();

    @Select("SELECT * FROM carousel WHERE id = #{id}")
    Carousel findById(Integer id);

    @Insert("INSERT INTO carousel(img, title, content, notice_id, is_valid) " +
            "VALUES(#{img}, #{title}, #{content}, #{notice_id}, #{is_valid})")
    int addCarousel(Carousel carousel);

    @Update("UPDATE carousel SET " +
            "img = #{img}, " +
            "title = #{title}, " +
            "content = #{content}, " +
            "notice_id = #{notice_id}, " +
            "is_valid = #{is_valid} " +
            "WHERE id = #{id}")
    int updateCarousel(Carousel carousel);

    @Delete("DELETE FROM carousel WHERE id = #{id}")
    int deleteCarousel(Integer id);
}